package org.singledog.dogmail.common.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * swagger2配置
 *
 * @author ZheMing Liu
 * @since 2022.1.18
 */
@Configuration
@EnableSwagger2
@EnableKnife4j
public class SwaggerConfig {


    private ApiInfo apiInfo(String name, String description, String version) {
        return new ApiInfoBuilder().title(name)
                .description(description)
                .version(version)
                .build();
    }

    @Bean
    public Docket shopExchangeApi() {
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo("单身狗商城api", "这个商城是宇宙最强的团体-单身狗联盟所创建，专门服务单身狗，有对象的请勿使用该商城", "1.0"))
                .useDefaultResponseMessages(false)
                .select()
                .apis(RequestHandlerSelectors.basePackage("org.singledog.dogmail.*.controller"))
                .paths(PathSelectors.any())
                .build()
                .groupName("单身狗")
                .pathMapping("/");
    }
}
